//
//  HomeCommonCell.m
//  CarUser
//
//  Created by 王森林 on 2018/12/4.
//  Copyright © 2018年 王森林. All rights reserved.
//

#import "HomeCommonCell.h"

@interface HomeCommonCell()
@property (nonatomic, strong) UIImageView *iconImageView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel  *typeLabel;
@property (nonatomic, strong) UILabel  *typeLabel1;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) NSDictionary *dict;
@end

@implementation HomeCommonCell


-(void)createUIWithData
{

    [self.contentView removeAllSubviews];
    [self.contentView addSubview:self.iconImageView];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.typeLabel];
    [self.contentView addSubview:self.typeLabel1];
    [self.contentView addSubview:self.priceLabel];
    
//    [self.iconImageView setImage:IMG(@"car_test1")];
    
    self.iconImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.iconImageView.clipsToBounds = YES;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:APPEND_URL(BASE_URL, [self.dict objectForKey:@"ZST000"])]];
    self.titleLabel.text = [self.dict objectForKey:@"CXMC00"];
    self.typeLabel.text = [self.dict objectForKey:@"GGBBMC"];
    self.typeLabel1.text = [self.dict objectForKey:@"GHFSMC"];
//    self.priceLabel.text = @"¥28.18万";
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@万",[self.dict objectForKey:@"ZDJG00"]];
    [self showSeparatorWithY:127.5];
    [self createConstraint];
 
    
}

- (void)createConstraint
{
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.left.equalTo(self.contentView.mas_left).offset(15);
        make.width.mas_equalTo(140);
        make.height.mas_equalTo(100);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(15);
        make.left.equalTo(self.iconImageView.mas_right).offset(6);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
    }];
    
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-15);
        make.left.equalTo(self.iconImageView.mas_right).offset(6);
        make.width.mas_equalTo(38);
        make.height.mas_equalTo(18);
    }];
    
    [self.typeLabel1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-15);
        make.left.equalTo(self.typeLabel.mas_right).offset(10);
        make.width.mas_equalTo(38);
        make.height.mas_equalTo(18);
    }];
    
    [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-15);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(18);
        make.right.equalTo(self.contentView.mas_right).offset(-15);
    }];
    
    
    
}

- (void)setData:(id)data
{
    if (data){
        self.dict = [NSDictionary dictionaryWithDictionary:data];
        [self createUIWithData];
    }
}

- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [UIImageView new];
        
    }
    return _iconImageView;
}


- (UILabel *)titleLabel
{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = Common_TextColor;
        _titleLabel.font = FONT_SIZE(14);
        _titleLabel.numberOfLines = 3;
    }
    return _titleLabel;
    
}

- (UILabel *)typeLabel
{
    if (!_typeLabel) {
        _typeLabel = [UILabel new];
        _typeLabel.textColor = Common_Text_TextfieldColor;
        _typeLabel.textAlignment = NSTextAlignmentCenter;
        _typeLabel.font = FONT_SIZE(12);
        _typeLabel.layer.borderWidth = 1;
        _typeLabel.layer.cornerRadius = 6;
        _typeLabel.layer.masksToBounds = YES;
        _typeLabel.layer.borderColor = Common_Head_Color.CGColor;
    }
    return _typeLabel;
    
}

- (UILabel *)typeLabel1
{
    if (!_typeLabel1) {
        _typeLabel1 = [UILabel new];
        _typeLabel1.textColor = Common_Text_TextfieldColor;
        _typeLabel1.textAlignment = NSTextAlignmentCenter;
        _typeLabel1.font = FONT_SIZE(12);
        _typeLabel1.layer.borderWidth = 1;
        _typeLabel1.layer.cornerRadius = 6;
        _typeLabel1.layer.masksToBounds = YES;
        _typeLabel1.layer.borderColor = Common_Head_Color.CGColor;
    }
    return _typeLabel1;
    
}

- (UILabel *)priceLabel
{
    if (!_priceLabel) {
        _priceLabel = [UILabel new];
        _priceLabel.textColor = Common_TextColor;
        _priceLabel.textAlignment = NSTextAlignmentRight;
        _priceLabel.font = B_FONT_SIZE(18);
        
    }
    return _priceLabel;
    
}

@end
